package com.baibei.ebec.sdk;

import com.baibei.model.BaseHttpResponse;
import com.baibei.model.CouponInfo;
import com.baibei.model.DeliveryQueryInfo;
import com.baibei.model.HeloInfo;
import com.baibei.model.HelpContentInfo;
import com.baibei.model.HttpResult;
import com.baibei.model.MergeOrderInfo;
import com.baibei.model.PercentInfo;
import com.baibei.model.RankingInfo;
import com.baibei.model.ResponseInfo;
import com.baibei.model.SuggestNumbersInfo;
import com.baibei.sdk.Empty;

import java.util.List;

import io.reactivex.Observable;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;

/**
 * 交易接口
 * Created by ChenRui on 2017/5/10 0010 18:22.
 */
public interface ITradeApi {


    /**
     * 现价订购
     *
     * @param productId   产品
     * @param area        区域
     * @param quantity    订购数量
     * @param topLimit    止盈
     * @param bottomLimit 止损
     * @return
     */
    @POST(ApiConstant.API_TRADE_BUY)
    @FormUrlEncoded
    Observable<Empty> buy(
            @Field("productId") String productId,
            @Field("area") String area,
            @Field("number") int quantity,
            @Field("amount") double amount,
            @Field("fee") double fee,
            @Field("toplimit") int topLimit,
            @Field("bottomlimit") int bottomLimit,
            @Field("isJuan") int isJuan,
            @Field("couponId") String couponId,
            @Field("couponType") int couponType);


    /**
     * 结算价订购
     *
     * @param productId   产品
     * @param area        区域
     * @param quantity    订购数量
     * @param topLimit    止盈
     * @param bottomLimit 止损
     * @return
     */
    @POST(ApiConstant.API_TRADE_SELL)
    @FormUrlEncoded
    Observable<Empty> sell(
            @Field("productId") String productId,
            @Field("area") String area,
            @Field("number") int quantity,
            @Field("amount") double amount,
            @Field("fee") double fee,
            @Field("toplimit") int topLimit,
            @Field("bottomlimit") int bottomLimit,
            @Field("isJuan") int isJuan,
            @Field("couponId") String couponId,
            @Field("couponType") int couponType);


    /**
     * 退订
     *
     * @param orderId 订单号
     * @param area    区域
     * @return
     */
    @POST(ApiConstant.API_TRADE_CANCEL)
    @FormUrlEncoded
    Observable<Empty> cancel(
            @Field("orderId") String orderId,
            @Field("area") String area);

    /**
     * 查询商品排行榜
     *
     * @param area 产区
     */
    @POST(ApiConstant.API_RANKING_LIST)
    @FormUrlEncoded
    Observable<List<RankingInfo>> getRankingList(@Field("area") String area);

    /**
     *
     */
    @POST(ApiConstant.API_RANKING_LIST_LONDON)
    Observable<List<RankingInfo>> getLondonRankingList();

    /**
     * 拼单列表
     *
     * @param page 页码
     * @return
     */
    @POST(ApiConstant.API_TRADE_MERGE_ORDER)
    @FormUrlEncoded
    Observable<List<MergeOrderInfo>> getMergeOrders(@Field("page") int page);

    /**
     * 补款取货
     *
     * @param orderId   订单
     * @param area      产区
     * @param addressId 收货地址
     * @return
     */
    @POST(ApiConstant.API_TRADE_APPLY_SETTLEMENT)
    @FormUrlEncoded
    Observable<Empty> settlement(@Field("orderId") String orderId, @Field("area") String area, @Field("addressId") String addressId);

    /**
     * 新增拼单
     */
    @POST(ApiConstant.API_TRADE_MERGE_ORDER_CREATE)
    @FormUrlEncoded
    Observable<Empty> createMergeOrder(@Field("productId") int productId,
                                       @Field("productName") String productName,
                                       @Field("crawdCount") int count,
                                       @Field("crawdPrice") double price,
                                       @Field("address") String address);

    /**
     * 拼单列表
     *
     * @param productId id
     * @return
     */
    @POST(ApiConstant.API_COUPON_USE_QUERY)
    @FormUrlEncoded
    Observable<List<CouponInfo>> getValidCouponList(@Field("productId") String productId);


    /**
     * 推荐商品
     */
    @POST(ApiConstant.API_SUGGEST_NUMBERS)
    Observable<SuggestNumbersInfo> getSuggestNumbers();

    /**
     * 修改止盈线
     */
    @FormUrlEncoded
    @POST(ApiConstant.API_RESET_TOP_LIMIT)
    Observable<HttpResult> resetTopLimit(@Field("orderId") String orderId,
                                         @Field("toplimit") String toplimit);

    /**
     * 查询订购比例
     */
    @POST(ApiConstant.API_QUERY_ORDER_PERCENT)
    Observable<PercentInfo> getPercent();

    /**
     * 获取提醒内容
     */
    @GET(ApiConstant.API_GET_HELP)
    Observable<List<HelpContentInfo>> getHelp();

    /**
     * 获取盈利榜提醒内容
     */
    @GET(ApiConstant.API_GET_WELFARE_HELP)
    Observable<List<HelpContentInfo>> getWelfareHelp();

}
